package com.pinyoumei.app.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.bean.ToDayPtBean;
import com.pinyoumei.app.view.SDAdaptiveTextView;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2021-08-09.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-09        Administrator             新增Person类
 * 2021-08-09        Administrator             增加sex属性
 */
public class PTorderAdapter extends BaseQuickAdapter<ToDayPtBean .ResultBean.OrderListBean, BaseViewHolder> {
    private int spell_status;
    public PTorderAdapter(int status, int layoutResId, @Nullable List<ToDayPtBean.ResultBean.OrderListBean> data) {
        super(layoutResId, data);
        spell_status = status;
    }

    @Override
    protected void convert(BaseViewHolder helper, ToDayPtBean .ResultBean.OrderListBean item) {

        SDAdaptiveTextView tv_order_no = helper.getView(R.id.tv_order_no);
        tv_order_no.post(new Runnable() {
            @Override
            public void run() {
                tv_order_no.setAdaptiveText("订单编号：" + item.getOrder_no());
            }
        });

        ImageView iv_bg = helper.getView(R.id.iv_bg);
        Glide.with(mContext).load(item.getGoods_img()).into(iv_bg);

        helper.setText(R.id.tv_goods_name,item.getGoods_name());
        helper.setText(R.id.tv_goods_num,"x" +item.getGoods_num());
        helper.setText(R.id.tv_goods_price,"¥" +item.getGoods_price());
        helper.setText(R.id.tv_goods_price,"¥" +item.getGoods_price());



        switch (spell_status) {
        	case 1:
                if (!TextUtils.isEmpty(item.getOrder_time())){
                    helper.setText(R.id.tv_order_time,"下单:" +item.getOrder_time());
                }
        		break;
            case 2:

                if (!TextUtils.isEmpty(item.getOrder_time())){
                    helper.setText(R.id.tv_order_time,"下单:" +item.getOrder_time());
                }

                if (!TextUtils.isEmpty(item.getSpelled_time())){
                    helper.setText(R.id.tv_spelled_time,"团中:" +item.getSpelled_time());
                }
                break;
            case 3:
                if (!TextUtils.isEmpty(item.getOrder_time())){
                    helper.setText(R.id.tv_order_time,"下单:" +item.getOrder_time());
                }

                if (!TextUtils.isEmpty(item.getSpell_open_time())){
                    helper.setText(R.id.tv_spelled_time,"开团:" +item.getSpell_open_time());
                }
                break;
        	default:
        		break;
        }





    }
}
